package test.time;

public class Z { 
	public static void main(String[] args) { 
		new Z(); 
	} 

	Z() { 
		Z alias1 = this; 
		Z alias2 = this; 
	
		synchronized(alias1) { 
			try { 
				System.out.println("WAITING"); 
				alias2.wait(); 
				System.out.println("DONE WAITING"); 
			} 
			catch (InterruptedException e) { 
				System.out.println("INTERRUPTED"); 
			} 
			catch (Exception e) { 
				System.out.println("OTHER EXCEPTION"); 
			} 
			finally { 
				System.out.println("FINALLY"); 
			} 
		} 

		System.out.println("ALL DONE"); 
	} 

} 

